package com.sh.data.engine.application.model.dto.integration;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.List;

@Data
@Schema
public class OfflineTaskCreateTableMappingResponse {

    @Schema(description = "来源表列表")
    private List<Table> sourceTables;

    @Schema(description = "目标表列表")
    private List<Table> targetTables;

    @Data
    @Schema
    public static class Table {

        @NotBlank(message = "表名不能为空")
        @Schema(description = "表名")
        private String name;

        @Schema(description = "字段列表")
        private List<Field> fields;

        @Schema(description = "表备注")
        private String comment;

        @Schema(title = "表是否存在", description = "0-不存在 1-存在")
        private Integer isExist = 1;

        @Schema(title = "分区是否匹配", description = "0-不匹配 1-匹配")
        private Integer isParitionMatch = 1;

        @Schema(title = "字段是否匹配", description = "0-不匹配 1-匹配")
        private Integer isFieldMatch = 1;

        public Table(String name) {
            this.name = name;
        }
    }

    @Data
    @Schema
    public static class Field {

        @Schema(description = "关键字")
        private String key;

        @Schema(description = "字段名")
        private String fieldName;

        @Schema(description = "字段类型（从db中读取到的）")
        private String fieldType;

        @Schema(description = "字段类型（对应的java.sql.Types的SQL类型）")
        private Integer dataType;

        @Schema(description = "字段长度")
        private Integer columnSize;

        @Schema(description = "字段小数位长度")
        private Integer decimalDigits;

        @Schema(description = "字段可否为空 0-NO  1-YES")
        private Integer nullAble;

        @Schema(description = "字段默认值")
        private String defaultValue;

        @Schema(description = "是否是分区字段")
        private Integer isParition = 0;

        @Schema(description = "字段是否是主键")
        private boolean isPk;

        @Schema(description = "字段备注")
        private String comment;
    }
}
